<template>
	<BaseContainer>
		<aplid-base-crud
			ref="crud"
			class="w-100"
			v-bind="{ ...theConfig, ...$attrs }"
			:paramsObj="{ isWithAuth: props.isWithAuth, code: 2021 }"
			:isComprehensiveQueries="isComprehensiveQueries"
		>
			<template v-slot:ArchivesDialog="{ row, show }">
				<Archives @refresh="handleRefresh" :api="baseConfig.api" :key="show" :nowRowData="row"></Archives>
			</template>
			<template v-slot:importDialog="{ row, show }">
				<ImportForm @refresh="handleRefresh" :api="baseConfig.api" :key="show" :nowRowData="row"></ImportForm>
			</template>
		</aplid-base-crud>
	</BaseContainer>
</template>

<script setup lang="ts">
import { baseConfig } from './config'
import { editConfig } from '@/views/datacenter/comprehensiveQueries/utils/index'
import Archives from './components/Archives/index.vue'
import ImportForm from './components/ImportForm/index.vue'
type Props = {
	isWithAuth?: any
	isComprehensiveQueries?: boolean
}
let props = withDefaults(defineProps<Props>(), {
	isWithAuth: undefined,
	isComprehensiveQueries: false,
})
let theConfig: any = ref({})
if (baseConfig) {
	let defaultConfig = JSON.parse(JSON.stringify(baseConfig))
	if (props.isComprehensiveQueries) {
		theConfig.value = editConfig(defaultConfig)
	} else {
		theConfig.value = baseConfig
	}
}

const crud = ref()
const handleRefresh = (query) => {
	nextTick(() => {
		crud.value.refreshChange(query)
	})
}
</script>

<style scoped></style>
